package com.azzaou.service.impl;

import java.util.List;

import com.azzaou.dao.IChantierDao;
import com.azzaou.dao.IClientDao;
import com.azzaou.dao.IMarchandiseDao;
import com.azzaou.model.CategorieEmploye;
import com.azzaou.model.CategorieMarchandise;
import com.azzaou.model.Marchandise;
import com.azzaou.service.IMarchandiseService;

public class MarchandiseService implements IMarchandiseService {

	IChantierDao chantierDao;
	IMarchandiseDao marchandiseDao;
	
	
	
	public IChantierDao getChantierDao() {
		return chantierDao;
	}

	public void setChantierDao(IChantierDao chantierDao) {
		this.chantierDao = chantierDao;
	}

	public IMarchandiseDao getMarchandiseDao() {
		return marchandiseDao;
	}

	public void setMarchandiseDao(IMarchandiseDao marchandiseDao) {
		this.marchandiseDao = marchandiseDao;
	}

	@Override
	public List<Marchandise> getMarchandiseByCriteria(Marchandise marchandise) {
		return marchandiseDao.getMarchandiseByCriteria(marchandise);
	}

	@Override
	public void saveOrUpdateMarchandise(Marchandise marchandise) {
		marchandiseDao.saveOrUpdateMarchandise(marchandise);

	}

	@Override
	public void removeMarchandise(Marchandise marchandise) {
		marchandiseDao.removeMarchandise(marchandise);

	}

	@Override
	public List<Marchandise> getAllActifMarchandise() {
		return marchandiseDao.getAllActifMarchandise();
	}

	@Override
	public void saveOrUpdateCategorie(CategorieMarchandise categorieMarchandise) {
		marchandiseDao.saveOrUpdateCategorie(categorieMarchandise);

	}

	@Override
	public void removeCategorie(CategorieMarchandise categorieMarchandise) {
		marchandiseDao.removeCategorie(categorieMarchandise);
		

	}

	@Override
	public List<CategorieMarchandise> getAllCategorie() {
		return marchandiseDao.getAllCategorie();
	}

	@Override
	public List<String> marchandisesByNames(String begin) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public CategorieMarchandise getCategorieMarchandiseById(Long id) {
		
		CategorieMarchandise categorieMarchandise = null;
			for (CategorieMarchandise cat : getAllCategorie())
			{
				if(cat.getId() == id)
				{
					categorieMarchandise = cat;
					break;
				}
			}
			return categorieMarchandise;
		
	}

	
	@Override
	public Marchandise getMarchandiseById(Long id) {
		
		Marchandise marchandise = null;
			for (Marchandise cat : getAllActifMarchandise())
			{
				if(cat.getId() == id)
				{
					marchandise = cat;
					break;
				}
			}
			return marchandise;
		
	}
}
